package com.fwmagic.redis;

import redis.clients.jedis.Jedis;

import java.util.Map;

/**
 * 存储HashSet
 */
public class HashValue {
    public static void main(String[] args) {
        Jedis jedis = new Jedis("192.168.62.131", 6379, 5000);
        //输入密码
        //jedis.auth("123456");

        //选择数据库，默认为0号数据库
        jedis.select(1);
        jedis.hset("shanghai", "pudong","babaiban");
        jedis.hset("shanghai", "songjiang","daxuecheng");
        jedis.hset("shanghai", "minhang","gongyuan");
        String value = jedis.hget("shanghai","pudong");
        System.out.println(value);

        Map<String, String> all = jedis.hgetAll("shanghai");

        all.forEach((k,v) -> System.out.println(k+":"+v));

        //删除
        jedis.hdel("shanghai","minhang");

        jedis.close();
    }
}
